package com.chinaunicom.system.controller;

import java.util.List; 

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.chinaunicom.system.model.datadictionary;
import com.chinaunicom.system.service.IdatadictionaryService;

@Controller
@RequestMapping("/sys/data")
public class DataController {

	@Resource
	private IdatadictionaryService datadictionaryService;
	
	@RequestMapping("/query")
	public String query(Model model){
		List<datadictionary> datadictionaries = datadictionaryService.query();
		List<datadictionary> fathers = datadictionaryService.queryFather();
		model.addAttribute("fathers", fathers);
		model.addAttribute("data", datadictionaries);
		return "/WEB-INF/system/data_list.jsp";
	}
	
	@RequestMapping("/queryByFatherId")
	public String queryByFatherId(Integer fid,Model model){
		List<datadictionary> d = datadictionaryService.queryById(fid);
		model.addAttribute("data", d);
		List<datadictionary> fathers = datadictionaryService.queryFather();
		model.addAttribute("fathers", fathers);
		System.out.println();
		return "/WEB-INF/system/data_list.jsp";
	}
	
}
